import time

import redis

redis_client = redis.StrictRedis(host='10.100.12.58', port=6379, db=0)

# 指定文件路径
file_path = r'F:\辛英杰\project\cd_nine\cd_playoff_wanji\net_file\example.txt'
while True:
    # 使用with语句确保文件正确关闭
    with open(file_path, 'r', encoding='utf-8') as file:
        # 逐行读取文件
        for line in file:
            # 去除行尾的换行符（可选）
            line = line.strip()
            redis_client.publish('CDJHS_GKQResult_YK004', line.replace("'",'"'))
            print('time：', time.time())
            time.sleep(0.1)